<!-- 消息详情 -->
<template>
  <div class='message_detail'>
    <Form ref="formAddEdit" :model="formAddEdit" :label-width="110">
      <FormItem label="标题：" prop="msgTitle">
        <span>{{formAddEdit.msgTitle}}</span>
      </FormItem>
      <FormItem label="发送对象：">
        {{formAddEdit.sendCompany=='00'?'全体人员':`${formAddEdit.sendCompanyName?formAddEdit.sendCompanyName:''+formAddEdit.sendPersonalName?formAddEdit.sendPersonalName:''}`}}
      </FormItem>
      <Row>
        <Col span="24">
        <FormItem label="发送时效：" prop="sendFlag">
          <span>{{formAddEdit.sendFlag==1?'实时发送':formAddEdit.sendFlag==2?'定时发送':'-'}}</span>
        </FormItem>
        </Col>
      </Row>
      <Row v-if='formAddEdit.sendPort'>
        <Col span="24">
        <FormItem label="发送端口：" prop="sendPort">
          <span>{{String(formAddEdit.sendPort).replace('2', '后台').replace('1', 'APP')}}</span>
        </FormItem>
        </Col>
      </Row>
      <Row v-if="formAddEdit.sendPort.indexOf('1')>-1">
        <Col span="24">
        <FormItem label="首页弹框：" prop="popFlag">
          <span>{{formAddEdit.popFlag==0?'否':'是'}}</span>
        </FormItem>
        </Col>
      </Row>
      <Row v-if="formAddEdit.sendFlag==2">
        <Col span="14">
        <FormItem label="发送时间：" prop="sendTime">
          <span>{{formAddEdit.sendTime}}</span>
        </FormItem>
        </Col>
      </Row>
      <FormItem label="发送内容：">
        <dt-editor-show :content='formAddEdit.sendContent' />
      </FormItem>
      <Row type="flex" justify="center" class="footer">
        <Button type="primary" @click="addEditReset()" style="margin-right: 8px">关闭</Button>
      </Row>
    </Form>
  </div>
</template>

<script>
  import msgApi from '@/biz/message'
  import dtEditorShow from '@/components/dt/editor/show'
  export default {
    components: {
      dtEditorShow
    },
    data() {
      return {
        formAddEdit: {
          msgTitle: '',
          sendCompany: [],
          sendFlag: 1,
          sendTime: '',
          sendPersonal: [],
          sendContent: '',
          jumpFlag: 1,
          jumpType: 1,
          sendPort: ''
        },
      }
    },
    computed: {},
    watch: {},
    methods: {
      //编辑时获取消息详情
      getMsgDetail(msgId) {
        let params = {
          msgId,
        }
        msgApi.getMessageDetails(params).then((res) => {
          console.log(res)
          this.formAddEdit = { ...res }
        })
      },
      //关闭
      addEditReset() {
        this.$router.replace({
          path: 'messageLog',
        })
      },
    },
    created() {},
    mounted() {
      if (this.$route.query && this.$route.query.type == 'view') {
        this.getMsgDetail(this.$route.query.msgId)
      }
    },
  }
</script>
<style lang='scss' scoped>
  .message_detail {
    padding: 20px;

    .M_top_10 {
      margin-top: 10px;
    }

    .editorContentsError {
      color: #ed4014;
      font-size: 14px;
      position: absolute;
      left: 0;
      bottom: -26px;
    }

    .footer {
      // background-color: #ffffff;
      position: fixed;
      bottom: 0px;
      width: 100%;
      height: 80px;
      margin-top: 40px;

      .ivu-btn {
        width: 100px;
        text-align: center;
        line-height: 32px;
      }
    }
  }
</style>